$(function () {
    $("#login_button").click(function () {
        //用户名
        var usernameText = $("#username").val();
        var usernamePatt = /^\w{5,12}$/;
        if(!usernamePatt.test(usernameText)){
            $("#errorMsg").text("用户名不合法！");
            return false;
        }

        //密码
        var passwordText = $("#password").val();
        var passwordPatt = /^\w{5,12}$/;
        if(!passwordPatt.test(passwordText)){
            $("#errorMsg").text("密码不合法！");
            return false;
        }
        var quepasswordText = $("#quepassword").val();
        if(!passwordText==quepasswordText){
            $("#errorMsg").text("密码与确认密码不一致！");
            return false;
        }

        //邮箱
        var emailText = $("#email").val();
        var emailPatt = /^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/;
        if(!emailPatt.test(emailText)){
            $("#errorMsg").text("邮箱不合法！");
            return false;
        }

        //验证码
        var codeText = $("#code").val();
        //去掉验证码前后空格
        codeText = $.trim(codeText);
        if(codeText == null || codeText == ""){
            $("#errorMsg").text("验证码不正确");
            return false;
        }

    });
});